/*******************************************************************************
*  file    : qlogger_.hpp
*  created : 01.05.2013
*  author  : 
*******************************************************************************/

#ifndef QLOGGER__HPP
#define QLOGGER__HPP

#include <QSharedPointer>
#include "qloggerconf.hpp"
#include "qloggerappender.hpp"
#include "qloggerevent.hpp"

class QLoggerAppender;

class QLOGGER_DECL QLogger:public QObject
{
    Q_OBJECT
public:
    explicit QLogger(QString moduleName, QObject *parent = 0);
    ~QLogger();

    void addAppender(QLoggerAppender *appender);
    void delAppender(QLoggerAppender *appender);
private:
    QList<QSharedPointer<QLoggerAppender> > appenders_;
    friend class QLoggerEngine;

public:
    QString name;
    void     log      (QLoggerLevel level, const QString &message, const char *file = "no file info",
                       int line = 0, const char* func = "no func info");
    void     log      (QLoggerEvent& event);
    QLogger& debug    (const QString &message, const char *file = "no file info",
                       int line = 0, const char* func = "no func info");
    QLogger& info     (const QString &message, const char *file = "no file info",
                       int line = 0, const char* func = "no func info");
    QLogger& warn     (const QString &message, const char *file = "no file info",
                       int line = 0, const char* func = "no func info");
    QLogger& error    (const QString &message, const char *file = "no file info",
                       int line = 0, const char* func = "no func info");
    QLogger& fatal    (const QString &message, const char *file = "no file info",
                       int line = 0, const char* func = "no func info");
    QLogger& critical (const QString &message, const char *file = "no file info",
                       int line = 0, const char* func = "no func info");
    QLogger& exception(const QString &message, const char *file = "no file info",
                       int line = 0, const char* func = "no func info");
protected:
    bool isEventAccepted (QLoggerAppender *appender, const QLoggerEvent &event);
};


#endif // QLOGGER__HPP
